ccR.Add_Rotation(
	1,
	"Ankhys_BASIC_Blood_DK",
	"BASIC Rotation.\n\nMade by Ankhy"
)

function Ankhys_BASIC_Blood_DK()
		if (ccR.Player.IsInCombat() or (ccR.Player.IsInGroup() and ccR.Target.IsInCombat())) and ccR.Target.Is.Attackable() then
		if ccR.Player.Has.Glyph(59332) and not ccR.Player.Has.Buff("Breath of Sindragosa") then
			if not ccR.Player.HasTalent("Necrotic Plague") and not ccR.Target.HasMyDebuff("Blood Plague") and ccR.Spell.IsReady("Outbreak") then ccR.Cast.Attack("Outbreak") end
			if not ccR.Player.HasTalent("Necrotic Plague") and not ccR.Target.HasMyDebuff("Frost Fever") and ccR.Spell.IsReady("Outbreak") then ccR.Cast.Attack("Outbreak") end
			if ccR.Player.HasTalent("Necrotic Plague") and not ccR.Target.HasMyDebuff("Necrotic Plague") and ccR.Spell.IsReady("Outbreak") then ccR.Cast.Attack("Outbreak") end	
		else	
			if not ccR.Player.HasTalent("Necrotic Plague") and (not ccR.Target.HasMyDebuff("Blood Plague") or ccR.Target.DebuffDuration("Blood Plague","<", 3)) and ccR.Spell.IsReady("Outbreak") then ccR.Cast.Attack("Outbreak") end
			if not ccR.Player.HasTalent("Necrotic Plague") and (not ccR.Target.HasMyDebuff("Frost Fever") or ccR.Target.DebuffDuration("Frost Fever","<", 3)) and ccR.Spell.IsReady("Outbreak") then ccR.Cast.Attack("Outbreak") end
			if ccR.Player.HasTalent("Necrotic Plague") and (not ccR.Target.HasMyDebuff("Necrotic Plague") or ccR.Target.DebuffDuration("Necrotic Plague","<", 1)) and ccR.Spell.IsReady("Outbreak") then ccR.Cast.Attack("Outbreak") end	
		end
		if ccR.Target.Count(8) > 0 and ccR.Spell.IsReady("Death and Decay") then ccR.Cast.AoE("Death and Decay", "target", 30, 8) end
		if ccR.Target.Count(8) > 0 and ccR.Spell.IsReady(152280) then ccR.Cast.AoE(152280, "target", 30, 8) end
		Plague_Leech()
		if ccR.Spell.Is.Ready("Blood Tap") and ccR.Player.Has.Talent("Blood Tap") and (ccR.Player.Has.Buff("Blood Charge") and ccR.Player.BuffStacks("Blood Charge") >= 5 and ccR.Spell.Is.Ready("Soul Reaper") and ccR.Target.Health() <= 45 and not ccR.Spell.CanAttack("Soul Reaper")) then if (not select(3, GetRuneCooldown(1)) and not select(3, GetRuneCooldown(2))) or (not select(3, GetRuneCooldown(3)) and not select(3, GetRuneCooldown(4))) or (not select(3, GetRuneCooldown(5)) and not select(3, GetRuneCooldown(6))) then ccR.Cast.Spell("Blood Tap") end end
		if ccR.Spell.IsReady("Death Strike") and ((ccR.Player.Rune_Count("Unholy") > 0 and ccR.Player.Rune_Count("Frost") > 0 ) or (ccR.Player.Rune_Count("Unholy") > 0 and ccR.Player.Rune_Count("Death") > 0 ) or (ccR.Player.Rune_Count("Frost") > 0 and ccR.Player.Rune_Count("Death") > 0 )) then ccR.Cast.Attack("Death Strike") end
		if ccR.Target.Count(8) > 2 and ccR.Spell.IsReady("Blood Boil") then ccR.Cast.Spell("Blood Boil") end
		if ccR.Spell.IsReady("Soul Reaper") and ccR.Player.Rune_Count("Blood") > 0 and ccR.Target.Health() <= 35 then ccR.Cast.Spell("Soul Reaper") end
		if ccR.Spell.IsReady("Blood Boil") and ccR.Player.Rune_Count("Blood") > 0 then ccR.Cast.Spell("Blood Boil") end
		if ccR.Spell.Is.Ready("Blood Tap") and ccR.Player.Has.Talent("Blood Tap") and (ccR.Player.Has.Buff("Blood Charge") and ccR.Player.BuffStacks("Blood Charge") >= 5) then if (not select(3, GetRuneCooldown(1)) and not select(3, GetRuneCooldown(2))) or (not select(3, GetRuneCooldown(3)) and not select(3, GetRuneCooldown(4))) or (not select(3, GetRuneCooldown(5)) and not select(3, GetRuneCooldown(6))) then ccR.Cast.Spell("Blood Tap") end end
		Plague_Leech_Last_Resort()
		if ccR.Spell.IsReady("Death Strike") then ccR.Cast.Attack("Death Strike") end
		if ccR.Spell.IsReady("Death Coil") then ccR.Cast.Attack("Death Coil") end
		if ccR.Spell.IsReady("Blood Boil") and ccR.Player.Has.Buff("Crimson Scourge") then ccR.Cast.Spell("Blood Boil") end
	end
end
local function Plague_Leech()
			local vRunesDepleted = 0
			for i= 1, 6 do 
				local start, duration, runeReady = GetRuneCooldown(i)
				if not runeReady and start > 0 and start < GetTime()-(duration/2) then vRunesDepleted = vRunesDepleted + 1 end
				--if not runeReady then vRunesDepleted = vRunesDepleted + 1 end
			end 
			if ccR.Spell.Is.Ready(PLAGUE_LEECH)	 
			and vRunesDepleted >= 2
			then
				for x = 1, #ccR_Enemies_Within_44 do 
					local vUnit = ccR_Enemies_Within_44[x] 
					if (
							(not ccR.Unit.Is.Boss(vUnit) and (ccR.Unit.Has.MyDebuff(vUnit, FROST_FEVER) and ccR.Unit.Has.MyDebuff(vUnit, BLOOD_PLAGUE)) or ccR.Unit.Has.MyDebuff(vUnit, NECROTIC_PLAGUE_DEBUFF))
							or
							(ccR.Unit.Is.Boss(vUnit) and (ccR.Unit.Has.MyDebuff(vUnit, FROST_FEVER) and ccR.Unit.MyDebuffDuration(vUnit, BLOOD_PLAGUE, "<=", 10)) or ccR.Unit.MyDebuffDuration(vUnit, NECROTIC_PLAGUE_DEBUFF, "<=", 10))
						)
					and ccR.Spell.CanAttack(PLAGUE_LEECH, vUnit) 
					and ccR.Player.Is.Facing(vUnit)
					then 
						ccR.Cast.Attack(PLAGUE_LEECH, vUnit)
					end
				end
			end
		end
		local function Plague_Leech_Last_Resort()
			local vRunesDepleted = 0
			for i= 1, 6 do 
				local start, duration, runeReady = GetRuneCooldown(i)
				if not runeReady and start > 0 and start < GetTime()-(duration/2) then vRunesDepleted = vRunesDepleted + 1 end
				--if not runeReady then vRunesDepleted = vRunesDepleted + 1 end
			end 
			if ccR.Spell.Is.Ready(PLAGUE_LEECH)	 
			and vRunesDepleted >= 2
			then
				for x = 1, #ccR_Enemies_Within_44 do 
					local vUnit = ccR_Enemies_Within_44[x] 
					if (ccR.Unit.Has.MyDebuff(vUnit, FROST_FEVER) and ccR.Unit.Has.MyDebuff(vUnit, BLOOD_PLAGUE) or ccR.Unit.Has.MyDebuff(vUnit, NECROTIC_PLAGUE_DEBUFF))
					and ccR.Spell.CanAttack(PLAGUE_LEECH, vUnit) 
					and ccR.Player.Is.Facing(vUnit)
					then 
						ccR.Cast.Attack(PLAGUE_LEECH, vUnit)
					end
				end
			end
		end